//
//  FirstViewController.swift
//  学唐诗
//
//  Created by 申克 on 16/5/10.
//  Copyright © 2016年 shang_hongzhi. All rights reserved.
//

import UIKit
import AVFoundation

class FirstViewController: UIViewController {
    
    @IBOutlet weak var topLabel: UILabel!
    @IBOutlet weak var midLabel: UILabel!
    var timer:NSTimer!
    var audio = AVAudioPlayer()
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        self.view.backgroundColor = UIColor.redColor()
        self.navigationController?.navigationBarHidden = true
        timer = NSTimer.scheduledTimerWithTimeInterval(3, target: self, selector: #selector(repretLabel), userInfo: nil, repeats: true)
//        // 创建目标队列
//        let workingQueue = dispatch_queue_create("my_queue", nil)
//        // 派发到刚创建的队列中，GCD 会负责进行线程调度
//        dispatch_async(workingQueue) {
//            NSThread.sleepForTimeInterval(2.5)  // 模拟两秒的执行时间
//            dispatch_async(dispatch_get_main_queue()) {
//               self.playWithSound()
//                
//            }
//        }
    }
    
    func repretLabel(){
        topLabel.twinkle()
        midLabel.twinkle()
    }
    @IBAction func exitButtonClick(sender: AnyObject) {
        exit(0)
    }
//    func playWithSound(){
////        
////        let path = NSBundle.mainBundle().pathForResource("footLeft", ofType: "wav")
////        let playerURL = NSURL.init(fileURLWithPath: path!)
////        do{
////        try audio = AVAudioPlayer(contentsOfURL: playerURL)
////        audio.numberOfLoops = 0;
////        audio .play()
////        }catch let error as NSError{
////            print(error.description)
////        }
//    }

    @IBAction func pushToNextController(sender: AnyObject) {
        let four = FourViewController()
        
        self.navigationController?.pushViewController(four, animated: true)
        
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
